
#import "Example2ViewController.h"

@implementation Example2ViewController

// Automatically build setters and getters methods
@synthesize labelsText;

// Implementation of clicked method.
// sender is the object that emitted the clicked action.
// The sender for this example will be either the red or blue button.
-(IBAction) clicked:(id)sender {
    
    // Get the title of the button and store it in a string.
    NSString *titleOfButton = [sender titleForState:UIControlStateNormal];
    
    // Construct the new text label string.
    NSString *newLabelText = [[NSString alloc]initWithFormat:@"%@", titleOfButton];
    
    // Set the label text variable to the new label we created.
    labelsText.text = newLabelText;

    // Free up memory (anything allocated or retained we should release!)
    [newLabelText release];
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
		
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
    
    // Release labelsText variable. i.e. set to nil
    self.labelsText = nil;
}


- (void)dealloc {
    [super dealloc];
    
    // Free up memory for labelsText variable.
    [labelsText release];
}

@end
